
package com.zb.springevent.event.listener;

import com.google.gson.Gson;
import com.zb.springevent.event.GoodsAddEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Author zb
 * @Date 2024/5/16 15:35
 */
@Component
@Slf4j
public class GoodsEventListener implements ApplicationListener<GoodsAddEvent> {
    
    @Async
    @Override
    public void onApplicationEvent(GoodsAddEvent event) {
        Gson gson = new Gson();
        log.info("监听到 GoodsAddEvent..." + gson.toJsonTree(event));
    }
}
